package com.misic.wed;

import com.misic.pojo.Song;
import com.misic.service.SongService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/song")
public class SongController {
    @Autowired
    private SongService songService;
    /**
     * 根据歌曲id查询歌曲对象
     */
    @GetMapping(value = "/detail")
    public Song detail(@RequestParam("songId") Integer songId){

        return songService.selectByPrimaryKey(songId);
    }
    /* * 根据歌手id查询歌曲
     */
    @GetMapping(value = "/singer/detail")
    public List<Song> songOfSingerId(@RequestParam("singerId")Integer singerId){
//        String singerId = request.getParameter("singerId");
        return songService.songOfSingerId(singerId);
    }
    /**
     * 根据歌手名字模糊查询歌曲
     */
    @GetMapping(value = "/likeSongOfName")
    public List<Song> likeSongOfName(@Param("songName")String songName){
//        String songName = request.getParameter("songName");
        return songService.likeSongOfName(songName);
    }

}
